package com.xcmg.kafka;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * KafkaApplication
 *
 * @author wangw
 * @create 2025-01-22 11:12
 **/

@SpringBootApplication
public class KafkaApplication implements CommandLineRunner {
    public static void main(String[] args) throws Exception {
        SpringApplication.run(KafkaApplication.class, args);

//        ConfigurableApplicationContext context = SpringApplication.run(KafkaApplication.class, args);
//        MessageProducer producer = context.getBean(MessageProducer.class);
//        producer.sendMessages();
//
//        Thread.sleep(5000);
//        context.close();
    }


    @Autowired
    private KafkaProducerConfig.MessageProducer messageProducer;

    @Override
    public void run(String... args) throws Exception {
        messageProducer.sendMessages();
    }
}
